package com.java110.mall.cart.smo.impl;

import com.java110.mall.cart.dao.IStoreStatisticsServiceDao;
import com.java110.dto.PageDto;
import com.java110.dto.mallReport.MallReportDto;
import com.java110.dto.mallReport.SellingCostDto;
import com.java110.intf.cart.IStoreStatisticsInnerServiceSMO;
import com.java110.utils.util.BeanConvertUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class StoreStatisticsInnerServiceSMOImpl implements IStoreStatisticsInnerServiceSMO {

    @Autowired
    private IStoreStatisticsServiceDao storeStatisticsServiceDaoImpl;


    @Override
    public List<MallReportDto> getInStockInfo(@RequestBody MallReportDto mallReportDto) {
        //校验是否传了 分页信息
        int page = mallReportDto.getPage();
        if (page != PageDto.DEFAULT_PAGE) {
            mallReportDto.setPage((page - 1) * mallReportDto.getRow());
        }
        List<MallReportDto> storeOrderUps = BeanConvertUtil.covertBeanList(storeStatisticsServiceDaoImpl.getInStockInfo(BeanConvertUtil.beanCovertMap(mallReportDto)), MallReportDto.class);

        return storeOrderUps;
    }

    @Override
    public int getInStockInfoCount(@RequestBody MallReportDto mallReportDto) {
        return storeStatisticsServiceDaoImpl.getInStockInfoCount(BeanConvertUtil.beanCovertMap(mallReportDto));
    }


    @Override
    public List<MallReportDto> getSalesInfo(@RequestBody MallReportDto mallReportDto) {
        //校验是否传了 分页信息
        int page = mallReportDto.getPage();
        if (page != PageDto.DEFAULT_PAGE) {
            mallReportDto.setPage((page - 1) * mallReportDto.getRow());
        }
        List<MallReportDto> storeOrderUps = BeanConvertUtil.covertBeanList(storeStatisticsServiceDaoImpl.getSalesInfo(BeanConvertUtil.beanCovertMap(mallReportDto)), MallReportDto.class);

        return storeOrderUps;
    }

    @Override
    public int getSalesInfoCount(@RequestBody MallReportDto mallReportDto) {
        return storeStatisticsServiceDaoImpl.getSalesInfoCount(BeanConvertUtil.beanCovertMap(mallReportDto));
    }

    @Override
    public List<MallReportDto> getInoutInfo(@RequestBody MallReportDto mallReportDto) {
        //校验是否传了 分页信息
        int page = mallReportDto.getPage();
        if (page != PageDto.DEFAULT_PAGE) {
            mallReportDto.setPage((page - 1) * mallReportDto.getRow());
        }
        List<MallReportDto> storeOrderUps = BeanConvertUtil.covertBeanList(storeStatisticsServiceDaoImpl.getInoutInfo(BeanConvertUtil.beanCovertMap(mallReportDto)), MallReportDto.class);

        return storeOrderUps;
    }

    @Override
    public int getInoutInfoCount(@RequestBody MallReportDto mallReportDto) {
        return storeStatisticsServiceDaoImpl.getInoutInfoCount(BeanConvertUtil.beanCovertMap(mallReportDto));
    }

    @Override
    public List<MallReportDto> getSalesRankingInfo(@RequestBody MallReportDto mallReportDto) {
        //校验是否传了 分页信息
        int page = mallReportDto.getPage();
        if (page != PageDto.DEFAULT_PAGE) {
            mallReportDto.setPage((page - 1) * mallReportDto.getRow());
        }
        List<MallReportDto> storeOrderUps = BeanConvertUtil.covertBeanList(storeStatisticsServiceDaoImpl.getSalesRankingInfo(BeanConvertUtil.beanCovertMap(mallReportDto)), MallReportDto.class);
        return storeOrderUps;
    }

    @Override
    public int getSalesRankingInfoCount(@RequestBody MallReportDto mallReportDto) {
        return storeStatisticsServiceDaoImpl.getSalesRankingInfoCount(BeanConvertUtil.beanCovertMap(mallReportDto));
    }

    @Override
    public List<SellingCostDto> getSellingCost(@RequestBody SellingCostDto sellingCostDto) {
        //校验是否传了 分页信息
        int page = sellingCostDto.getPage();
        if (page != PageDto.DEFAULT_PAGE) {
            sellingCostDto.setPage((page - 1) * sellingCostDto.getRow());
        }
        List<SellingCostDto> sellingCostDtos = BeanConvertUtil.covertBeanList(storeStatisticsServiceDaoImpl.getSellingCost(BeanConvertUtil.beanCovertMap(sellingCostDto)), SellingCostDto.class);
        return sellingCostDtos;
    }

    @Override
    public int getSellingCostCount(@RequestBody SellingCostDto sellingCostDto) {
        return storeStatisticsServiceDaoImpl.getSellingCostCount(BeanConvertUtil.beanCovertMap(sellingCostDto));
    }
    @Override
    public List<SellingCostDto> getSellingCostDetail(@RequestBody SellingCostDto sellingCostDto) {
        //校验是否传了 分页信息
        int page = sellingCostDto.getPage();
        if (page != PageDto.DEFAULT_PAGE) {
            sellingCostDto.setPage((page - 1) * sellingCostDto.getRow());
        }
        List<SellingCostDto> sellingCostDtos = BeanConvertUtil.covertBeanList(storeStatisticsServiceDaoImpl.getSellingCostDetail(BeanConvertUtil.beanCovertMap(sellingCostDto)), SellingCostDto.class);
        return sellingCostDtos;
    }

    @Override
    public int getSellingCostDetailCount(@RequestBody SellingCostDto sellingCostDto) {
        return storeStatisticsServiceDaoImpl.getSellingCostDetailCount(BeanConvertUtil.beanCovertMap(sellingCostDto));
    }

}
